Skip to content

feat: Implement setNamespace method#65

Open
artengin wants to merge 4 commits into
masterfrom
implement-set-namespace-method
Open

feat: Implement setNamespace method#65
artengin wants to merge 4 commits into
masterfrom
implement-set-namespace-method

Conversation

@artengin
Copy link
Copy Markdown
Contributor

No description provided.

@artengin artengin self-assigned this Apr 30, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94ee5d5fdb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Visitors/SetNamespace.php Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 30, 2026

Coverage Report for CI Build 25510203956

Coverage increased (+0.06%) to 98.615%

Details

  • Coverage increased (+0.06%) from the base build.
  • Patch coverage: 14 of 14 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 361
Covered Lines: 356
Line Coverage: 98.61%
Coverage Strength: 9.43 hits per line

💛 - Coveralls

@artengin
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f34e2fb06a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Visitors/SetNamespace.php Outdated
{
foreach ($nodes as $node) {
if ($node instanceof Namespace_) {
if ($node->name->toString() === $this->namespace) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle anonymous namespace node before comparing names

Guard this comparison against Namespace_ nodes whose name is null (for example, files using namespace { ... } global blocks). In that case, calling toString() throws at runtime, so setNamespace() crashes instead of rewriting the file. This regression is input-dependent but affects valid PHP files that parse to anonymous namespace nodes.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anonymous namespaces cannot be PSR-4 autoloaded, so this case is intentionally not supported.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3631d2807

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +26 to +29
if ($node instanceof Declare_) {
$declares[] = $node;

unset($nodes[$key]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict declare hoisting to leading strict_types

The new namespace insertion path hoists every top-level declare out of its original position before wrapping the rest of the file in namespace ...;. This changes runtime behavior for valid files that use non-strict_types declares (for example declare(ticks=1);) after some statements, because the directive is now applied from the top of the script. To avoid semantic changes, only preserve leading declare(strict_types=1) (or otherwise reject unsupported declare layouts) instead of relocating all Declare_ nodes.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants